package demo1;

import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class Test {

    public static void main(String[] args) {
        List<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        System.out.println(list);
        //迭代器，正序输出
        ListIterator<Integer> it = list.listIterator();
        while(it.hasNext()){
            System.out.println(it.next() + " ");
        }
        //倒序输出
        ListIterator<Integer> it2 = list.listIterator(list.size());
        while(it.hasPrevious()){
            System.out.println(it.next() + " ");
        }
    }
    //迭代器


    public static void main2(String[] args) {
        MyLinkedList myLinkedList =new MyLinkedList();
        myLinkedList.addLast(1);
        myLinkedList.addLast(2);
        myLinkedList.addLast(3);
        myLinkedList.addLast(4);
        myLinkedList.addLast(5);
        //System.out.println(myLinkedList.size());
        //System.out.println(myLinkedList.contains(10));

        myLinkedList.addIndex(0 , 99);
        myLinkedList.display();

    }

}

